xl: fix broken xl vcpu-list output (tool hangs on large machines)
authorAndre Przywara <andre.przywara@amd.com>
Fri, 4 Feb 2011 17:32:39 +0000 (17:32 +0000)
committerAndre Przywara <andre.przywara@amd.com>
Fri, 4 Feb 2011 17:32:39 +0000 (17:32 +0000)
commit89cff809686100fa2825032373d327a5f8c34dc6
tree4ffac1cc6463c9b937aba229c9533e58b269f3e2
parent7990584bb09ca04f5c79fa832d763d35ad0eae59
xl: fix broken xl vcpu-list output (tool hangs on large machines)

The algorithm for printing the CPU affinity in a condensed way
looks for a set bit in a zero-byte:
             for (i = 0; !(pcpumap & 1); ++i, pcpumap >>= 1)
Looking at the code I found that it is entirely broken if more than 8
CPUs are used. Beside that endless loop issue the output is totally
bogus except for the "any CPU" case, which is handled explicitly earlier.
I tried to fix it, but the whole approach does not work if the outer
loops actually iterates (executing more than once).
This fix reimplements the whole algorithm in a clean (though not much
optimized way). It survived some unit-testing.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl_cmdimpl.c